﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Annotations;
using SharedGenomics.Workbench.Core;

namespace SharedGenomics.Workbench.Presenters
{
    public class GeneSummaryAnnotationMenuProvider : IAnnotationMenuProvider
    {
        public GeneSummaryAnnotationMenuProvider(CommandFactory commandFactory, IMenuFactory menuFactory)
        {
            this.CommandFactory = commandFactory;
            this.MenuFactory = menuFactory;
        }

        #region IAnnotationMenuProvider Members

        public IMenuItem CreateMenu(IAnnotation annotation)
        {
            GeneSummaryAnnotation geneAnnotation = (GeneSummaryAnnotation)annotation;
            SharedGenomics.Domain.Gene gene = geneAnnotation.Gene;

            IMenuItem menu = this.MenuFactory.CreateContextMenuItem();

            menu.DisplayText = String.Format("Gene: {0}", gene.Name ?? "<null>");
            menu.Command = this.CommandFactory.CreateOpenPresenterAnnotationCommand <GeneSummaryPresenter>(FormDisplayMode.NonModalDialog, p => p.Annotation = geneAnnotation, geneAnnotation);

            return menu;
        }

        public Type AnnotationType
        {
            get { return typeof(GeneSummaryAnnotation); }
        }

        #endregion

        private CommandFactory CommandFactory { get; set; }
        private IMenuFactory MenuFactory { get; set; }
    }
}
